package com.baixun.gasentity.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: 上海燃气驾驶舱
 * @description: sys_deparment 实体类
 * @author: yesong
 **/

@Data
@TableName("sys_department")
public class SysDepartment implements Serializable {

    @TableId(type = IdType.AUTO)
    private Long id; // 部门ID

    private Long parentId; // 父部门ID

    private String name; // 部门名称

    private Boolean leaf; // 是否为最后一级部门，默认为0

    @TableLogic
    private Boolean deleted; // 逻辑删除标志，1表示已删除，0表示未删除

    private LocalDateTime createTime; // 记录创建时间

    // 子部门列表
    @TableField(exist = false) // 表示该字段不存储到数据库
    private List<SysDepartment> children;

    public List<SysDepartment> getChildren() {
        if (children == null) {
            children = new ArrayList<>();
        }
        return children;
    }

    public void setChildren(List<SysDepartment> children) {
        this.children = children;
    }

}
